//
//  OADLayout7ViewController.m
//  OASDK_Works
//
//  Created by ChenJie on 4/9/20.
//  Copyright © 2020 Mist. All rights reserved.
//

#import "OADLayout7ViewController.h"
#import "OABase.h"
#import "OALayout.h"

#define kMarginH 10
#define kMarginTop 10

@interface OADLayout7ViewController ()

@property (nonatomic, strong) UIView *container;
@property (nonatomic, strong) UIView *node1;
@property (nonatomic, strong) UIView *node11;
@property (nonatomic, strong) UIView *node111;
@property (nonatomic, strong) UIView *node112;
@property (nonatomic, strong) UIView *node12;
@property (nonatomic, strong) UIView *node2;
@property (nonatomic, strong) UIView *node3;
@property (nonatomic, strong) UIView *node31;

@end

@implementation OADLayout7ViewController

#pragma mark - ViewController lifecycle

- (instancetype)init {
    self = [super init];
    if (self) {
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = NSStringFromClass(self.class);
    
    //
    [self.view addSubview:self.container];
    
    [self.container addSubview:self.node1];
    [self.node1 addSubview:self.node11];
    [self.node11 addSubview:self.node111];
    [self.node11 addSubview:self.node112];
    [self.node1 addSubview:self.node12];
    [self.container addSubview:self.node2];
    
    //
//    OALayout.boxSizing = OABoxSizingContentBox;
    [self.container oa_showBoundsWithAlpha:0.5];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}

- (void)viewWillLayoutSubviews {
    [super viewWillLayoutSubviews];
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    
    //
    [self.container.oa_layout applyLayout];
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

#pragma mark - Public methods



#pragma mark - Private methods



#pragma mark - Event response methods

- (void)buttonClicked:(UIButton *)button {
    NSLog(@"button clicked...");
}

#pragma mark - Deletate methods



#pragma mark - Setter



#pragma mark - Getter

OAGetView(container, ^(UIView *view){
    [view oa_layoutStyle:((OALayoutStyle){
        .marginTop = OA_NAVIGATION_BAR_BOTTOM,
        .padding = 10,
    })];
})

OAGetView(node1, ^(UIView *view){
    [view oa_layoutStyle:((OALayoutStyle){
        .flexDirection = OAFlexDirectionRow,
        .justifyContent = OAJustifyCenter,
        .alignItems = OAAlignCenter,
        .margin = 5,
        .padding = 10,
        .flex = 1,
    })];
})

OAGetView(node11, ^(UIView *view){
    [view oa_layoutStyle:((OALayoutStyle){
        .justifyContent = OAJustifyFlexEnd,
        .alignItems = OAAlignFlexEnd,
        .margin = 5,
        .padding = 10,
        .flex = 1,
    })];
})

OAGetView(node111, ^(UIView *view){
    [view oa_layoutStyle:((OALayoutStyle){
        .justifyContent = OAJustifyFlexEnd,
        .alignItems = OAAlignFlexEnd,
        .margin = 5,
        .marginBottom = 25,
        .width = 50,
        .height = 50,
        .flex = 1,
    })];
})

OAGetView(node112, ^(UIView *view){
    [view oa_layoutStyle:((OALayoutStyle){
        .padding = 5,
        .width = 50,
        .height = 50,
    })];
})

OAGetView(node12, ^(UIView *view){
    [view oa_layoutStyle:((OALayoutStyle){
        .margin = 5,
        .width = 50,
        .height = 50,
    })];
})

OAGetView(node2, ^(UIView *view){
    [view oa_layoutStyle:((OALayoutStyle){
        .margin = 5,
        .width = 70,
        .height = 80,
        .flex = 1,
    })];
})

OAGetView(node3, ^(UIView *view){
    
})

OAGetView(node31, ^(UIView *view){
    
})

#pragma mark - Memory management

- (void)dealloc {
    NSLog(@"%s", __PRETTY_FUNCTION__);
}

@end
